// 封装购物车相关接口
import request from "@/utils/http";

/**
 *
 * @param {*} param0 加入购物车
 * @returns
 */
export const insertCartAPI = ({ skuId, count }) => {
  return request({
    url: "/member/cart",
    method: "POST",
    data: {
      skuId,
      count,
    },
  });
};

/**
 *
 * @returns 获得最新购物车列表
 */
export const findNewCartListAPI = () => {
  return request({
    url: "/member/cart",
  });
};

/**
 *
 * @param {*} ids 要删除的id，是一个数组
 * @returns
 */
export const delCartAPI = (ids) => {
  return request({
    url: "/member/cart",
    method: "DELETE",
    data: {
      ids,
    },
  });
};

/**
 *
 * @param {*} data 参数是数组
 * @returns
 */
export const mergeCartAPI = (data) => {
  return request({
    url: "/member/cart/merge",
    method: "POST",
    data,
  });
};
